package com.youlv.yl.controller;


import com.youlv.yl.dto.OrderPayDto;
import com.youlv.yl.dto.PayRefundDto;
import com.youlv.yl.service.intf.OrderPayService;
import com.youlv.yl.vo.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单支付表 前端控制器
 * </p>
 *
 * @author fenghe
 * @since 2022-01-25
 */
@CrossOrigin
@RestController
@RequestMapping("/yl/orderPay")
@Api(value = "实现了支付相关操作", tags = "实现了支付相关操作")
public class OrderPayController {

    @Autowired
    private OrderPayService service;

    /** 下单-生成支付信息*/
    @PostMapping("savePay.do")
    public R save(@RequestBody OrderPayDto dto) {
        return service.createPay(dto);
    }

    /** 取消订单支付*/
    @GetMapping("closePay.do")
    public R close(String no) {
        return service.closePay(no);
    }

    /** 查询订单的支付状态*/
    @GetMapping("queryPay.do")
    public R query(String no) {
        return service.queryPay(no);
    }

    /** 查询支付订单信息*/
    @GetMapping("all.do")
    public R all() {
        return service.queryAll();
    }

    /** 退款*/
    @PostMapping("refund.do")
    public R refund(@RequestBody PayRefundDto dto) {
        return service.refundPay(dto);
    }
}
